package testcase.userdata;

import basic.BasicCase;
import io.appium.java_client.TouchAction;
import org.openqa.selenium.By;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.Test;

import javax.swing.*;

/**
 * Created by 13714526025 on 2018/9/20.
 */
public class UpdateUserImage extends BasicCase {
    @Test
    public void testName() throws InterruptedException {
        finder.waitforWebElement("com.oppo.ohome:id/iv_setting");
        helper.getHomePage().userNameClick();
        //点击头像
        finder.findElementById("com.oppo.usercenter:id/user_avatar_img").click();
        finder.findElementByText("选择照片").click();
        //判断控件是否存在，存在就执行操作
        if (finder.isElementExist(By.id("oppo:id/oppo_security_content")) == true) {
            finder.findElementByText("同意并继续").click();
        }
        //从相机中选择照片（按照点击屏幕坐标的方式）
        TouchAction action = new TouchAction(driver);
        action.tap(350, 500).perform();

        Thread.sleep(3000);
        TouchAction action1 = new TouchAction(driver);
        action1.tap(300, 250).perform();
        finder.waitforWebElement("com.coloros.gallery3d:id/action_apply");
        finder.findElementById("com.coloros.gallery3d:id/action_apply").click();

    }
}